k=[] for num in range(1,1000): s=0 for i in range(1,num): if(num%i==0): s+=i if(s==num): k.append(num) print("Perfect numbers between 100 and 1000 are:") for i in range(len(k)): print(k[i]) input("Press enter to exit")